<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Object.fromEntries</title>
  </head>
  <body>
    <script>
      // 二维数组
      const result = Object.fromEntries([
        ["name", "张三"],
        ["age", "18"],
        ["tel", "9892068902"],
      ]);
      console.log(result);
      // Map
      const m = new Map([
        ["age", "18"],
        ["tel", "9892068902"],
      ]);
      m.set("name", "张三");
      const result1 = Object.fromEntries(m);
      console.log(result1);

      // Object.entries() 将对象转换为二维数组
      const arr = Object.entries(result);
      console.log(arr);
    </script>
  </body>
</html>
